import {request} from '@umijs/max';
import * as API from "@/services";
import {JournalPeriod_Sta} from "@/services";


/** 期刊分期 分页检索请求 */
export async function queryFrontJournalPeriods(params: API.FrontJournalPeriodPageQueryParams): Promise<API.RespPageResult<API.FrontJournalPeriod>> {
  return request('/api/v1/front/journal-period', {
    params,
  });
}

/** 期刊分期 详情请求 */
export async function queryFrontJournalPeriod(bizId: API.EntityId): Promise<API.RespResult<API.FrontJournalPeriod>> {
  return request(`/api/v1/front/journal-period/${bizId}`);
}


export async function queryFrontJournalPeriodYearStat(journalId: API.EntityId): Promise<API.RespListResult<API.JournalPeriod_Sta>> {
  return request(`/api/v1/front/journal-period/journal/${journalId}/year-num`);
}

export async function existFrontJournalPeriod(journalId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/front/journal-period/journal/${journalId}/exist`);
}


/**
 * 下载PDF(权限检查)
 */
export async function preCheckJournalPeriodDownload(bizId: API.EntityId, opts?: API.AxiosRequestOpts): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/front/journal-period/${bizId}/pdf/pre-check`, {
    method: "POST",
    ...(opts || {}),
  });
}
